<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/front/include/taglib.jsp"%>
<%@ include file="/WEB-INF/front/include/header.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
	<div style="width: 100%; overflow: auto;height:77%;margin: 0 auto;">
		<div style="text-align: center;">
			<input type="hidden" name="id" value="${activity.id}">
			<div  style="padding-top: 40px;padding-bottom: 40px;font-size: 30px;color: #373d41;letter-spacing: 1px;line-height: 36px;">
				${activity.title }
			</div>
			<div  style="font-size: 20px;color: #373d41;letter-spacing: 1px;line-height: 26px;">
				时间：<fmt:formatDate value="${activity.activityTime}" pattern="yyyy-MM-dd HH:mm"/>
				地点：${activity.address }
			</div>
			<div  style="font-size: 20px;">
				${activity.content}
			</div>
		</div>	
			<section class="pinlun_wap">
				<!-- 已有评论 -->
				<div class="yipinglun" style="margin:0px auto; padding-top:20px;">
					<c:if test="${evaluateList==null||evaluateList.size()==0 }">
					<h4>暂无评论</h4>
					</c:if>
				 	<c:if test="${evaluateList!=null and evaluateList.size()>0 }">
				 		<ul class="yipinglun_list"><span style="font-size:20px;">评论：</span>
				 		<c:forEach items="${evaluateList }" var="evaluate">
					 		 <li><p>${evaluate.studentName }：
			            		<span><fmt:formatDate value="${evaluate.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/> </span>
			            		</p>
			            		${evaluate.content}
			                 </li>
			                 <c:if test="${evaluate.imgUrl ne null}">
				                 <li>
				                 	<img alt="" src="${pageContext.request.contextPath}/${evaluateList.imgUrl}">
				                 </li>
			                 </c:if>
				 		</c:forEach>
				 		</ul>
				 	</c:if>
				</div>
				<c:if test="${frontUser!=null }">
					<input type="hidden" id="studentId" name="studentId" value="${frontUser.id }"/>
					<input type="hidden" id="activityId" name="activityId" value="${activity.id }"/>
					<div class="pinlun_xie">
						<div class="pinlun_xie_row2">写评论：</div>
						<input type="text" placeholder="随便说说你的想法，或者有什么问题？和大家一起探讨吧" id="content" maxlength="200">
						<div class="pinlun_xie_row4">
							<div class="pinlun_xie_row4_right">
								<span>还可以输入200字</span>
								<div onclick="saveComment();">发布</div>
							</div>
						</div>
					</div>
				</c:if>
			</section>
		
	</div>
</body>
<script type="text/javascript">
//发表评论
function saveComment(){
	var commentText=$().val();
	$.ajax({
		url:'${ctx}/saveEvaluate',
		type:"POST",
		dataType:"json",
		data:{'activityId':$("#activityId").val(),'studentId':$("#studentId").val(),'content':$("#content").val()},
		success:function(data){
			if("fail"==data){
				alert("评论失败");
			}else{
			$("#content").val("");
			var html='<li><p>${frontUser.name}：';
			html+='<span>'+data.createTime+'</span></p>';
			html+=data.content+'</li>';
			$(".yipinglun_list").append(html);
			}
		}
	});
}
</script>
<%@ include file="/WEB-INF/front/include/footer.jsp"%>
</html>